/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package dbbeans;

import java.io.Serializable;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author Laur
 */
@Entity
@Table(name = "nodes", catalog = "wad", schema = "")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Nodes.findAll", query = "SELECT n FROM Nodes n"), // NQ used to select all the nodes
    @NamedQuery(name = "Nodes.findById", query = "SELECT n FROM Nodes n WHERE n.id = :id"), // NQ used to select a node by id
    @NamedQuery(name = "Nodes.findByName", query = "SELECT n FROM Nodes n WHERE n.name = :name"), // NQ used to select nodes by their names
    @NamedQuery(name = "Nodes.findByParent", query = "SELECT n FROM Nodes n WHERE n.parent = :parent"), // NQ used to select nodes by their parent
    @NamedQuery(name = "Nodes.findByTree", query = "SELECT n FROM Nodes n WHERE n.tree = :tree")}) // NQ used to select nodes of a tree
public class Nodes implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @NotNull
    @Column(name = "id", nullable = false)
    private Integer id;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 50)
    @Column(name = "name", nullable = false, length = 50)
    private String name;
    @Basic(optional = false)
    @NotNull
    @Lob
    @Size(min = 1, max = 2147483647)
    @Column(name = "value", nullable = false, length = 2147483647)
    private String value;
    @Basic(optional = false)
    @NotNull
    @Column(name = "parent", nullable = false)
    private int parent;
    @Basic(optional = false)
    @NotNull
    @Column(name = "tree", nullable = false)
    private int tree;

    // constuctors used to instantiate this bean
    public Nodes() {
    }

    public Nodes(Integer id) {
        this.id = id;
    }

    public Nodes(Integer id, String name, String value, int parent, int tree) {
        this.id = id;
        this.name = name;
        this.value = value;
        this.parent = parent;
        this.tree = tree;
    }

    // getters and setters
    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }

    public int getParent() {
        return parent;
    }

    public void setParent(int parent) {
        this.parent = parent;
    }

    public int getTree() {
        return tree;
    }

    public void setTree(int tree) {
        this.tree = tree;
    }
    // auto generated hashcode() and equals()
    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Nodes)) {
            return false;
        }
        Nodes other = (Nodes) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "dbbeans.Nodes[ id=" + id + " ]";
    }
    
}
